var path = require('path');
var webpack = require('webpack');
var node_modules_dir = path.resolve(__dirname, 'node_modules');

var config = {

    entry: [
        path.resolve(__dirname, 'app/main.js')
    ],

    /** 打包的出口文件*/
    output: {
        publicPath: './',
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                loader: 'babel-loader',
                exclude: [node_modules_dir],
                query: {
                    presets: ['es2015', 'stage-0', 'react']
                }
            },
            {
                /** 编译sass文件*/
                test: /\.scss$/,
                loader: 'style!css!sass'
            }, {
                /** 图片如果不大于 25KB 的话要自动转成 BASE64 字符串*/
                /** loader的&name=img/[name].[ext]  指定了图片要放在img文件夹下*/
                test: /\.(png|jpg)$/,
                loader: 'url?limit=25000&name=img/[name].[ext]'
            }, {
                test: /\.css$/,
                loader: 'style-loader!css-loader!postcss-loader'
            }
        ]
        // noParse: [pathToReact , pathToReacttow]
    },
    plugins: [
        new webpack.DefinePlugin({
            "process.env": {
                NODE_ENV: JSON.stringify("production")
            }
        })
    ]

};

module.exports = config;